﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace CuteRibs.MVVMLib.ValueConverters
{
	public class AlternatingConverter : IValueConverter
	{
		private bool isAlternate;

		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			var pair = value as Pair<object>;
			var brush = this.isAlternate ? pair.Item2 : pair.Item1;
			this.isAlternate = !isAlternate;
			return brush;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			throw new NotImplementedException();
		}
	}
}
